home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / Apps / DevTools / eText5 / Source / MailTo.subproj / MailToUI.m < prev    next >
Encoding:
Text File  |  1994-11-01  |  2.9 KB  |  107 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //    FILENAME:    MailToUI.m 
  3. //    SUMMARY:    Interface for a UI for setting address and subject
  4. //    SUPERCLASS:    Object
  5. //    INTERFACE:    MailToUI.nib
  6. //    PROTOCOLS:    <Inspectable>
  7. //    AUTHOR:        Rohit Khare and Tom Zavisca
  8. //    COPYRIGHT:    (c) 1994 California Institure of Technology, eText Project
  9. ///////////////////////////////////////////////////////////////////////////////
  10. //    IMPLEMENTATION COMMENTS
  11. //        Just maintains two lousy fields.
  12. ///////////////////////////////////////////////////////////////////////////////
  13. //    HISTORY
  14. //    07/20/94:    Revamped to leverage eTImageUI in an "inspection chain"
  15. //    07/04/94:    Minimal Creation.
  16. ///////////////////////////////////////////////////////////////////////////////
  17.  
  18. #import "MailTo.h"
  19.  
  20. @implementation MailToUI
  21.  
  22. + new
  23. {
  24.     static MailToUI *ui = nil;
  25.     
  26.     if (!ui) {
  27.         ui = [[MailToUI alloc] init];
  28.     }
  29.     return ui;
  30. }
  31. - init
  32. {
  33.     char        buf[MAXPATHLEN];
  34.     NXBundle   *bundle;
  35.  
  36.     [super init];
  37.     bundle = [NXBundle bundleForClass:[MailToUI class]];
  38.     if ( [bundle getPath:buf forResource:"MailToUI" ofType:"nib"] ) {
  39.         [NXApp loadNibFile:buf owner:self withNames:NO];
  40.     } else {
  41.         NXLogError("NIB not found: MailToUI");
  42.     }
  43.     mailToView = [mailToPanel contentView];
  44.     return self;
  45. }
  46. - free {return self;}
  47. ///////////////////////////////////
  48. #define PROP "MailTo Properties"
  49. - (const NXAtom *) types
  50. {
  51.     static NXAtom *types = NULL;
  52.     
  53.     if (!types) {
  54.         int i;
  55.         const NXAtom *superTypes = [super types];
  56.         
  57.         for(i=0;superTypes[i];i++);
  58.         i++; // make room for terminating NULL
  59.         i++; // make room for our type
  60.         types = malloc(i * sizeof(NXAtom));
  61.         types[0] = NXUniqueString(PROP);
  62.         for(i=0;superTypes[i];i++) types[i+1] = superTypes[i];
  63.         types[i+1] = NULL;
  64.     }
  65.     return types;
  66. }
  67. - (const char *) inspectorTitle
  68. {
  69.     return NXUniqueString("MailTo");
  70. }
  71. - resignInspector: (View *) oldInspector ofType: (const char *) type
  72. {
  73.     if (oldInspector == mailToView) {
  74.         [self changeAddress:addressField];
  75.         [self changeSubject:subjectField];
  76.     } else 
  77.         [super resignInspector:oldInspector ofType:type];
  78.     return self;
  79. }
  80. - activateInspector: (View *) newInspector ofType: (const char *) type
  81. {
  82.     if (newInspector != mailToView)
  83.         [super activateInspector:newInspector ofType:type];
  84.     return self;
  85. }
  86. - inspectorForType:(const char *) type
  87. {
  88.     if(!strcmp(type,NXUniqueString(PROP)))
  89.         return mailToView;
  90. //    else NXLogError("Massive Inspector Failure: Asked MailTo for: %s", type);
  91. //    return mailToView;
  92.     return [super inspectorForType:type];
  93. }
  94. ////////////////////
  95. - setAnnotation:sender
  96. {
  97.     [super setAnnotation:sender];    // this is an awkward naming of the "chain" 
  98.     theMailTo = sender;
  99.     [addressField setStringValue:[theMailTo address]];
  100.     [subjectField setStringValue:[theMailTo subject]];
  101.     return self;
  102. }
  103. - changeAddress:sender
  104.     {[theMailTo setAddress:NXUniqueString([sender stringValue])]; return self;}
  105. - changeSubject:sender
  106.     {[theMailTo setSubject:NXUniqueString([sender stringValue])]; return self;}
  107. @end;